﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IntelliTouchMix
{

    public class DistSpeedTimeVect
    {
        public float speed;
        public float dist;
        public int time;
        public ActionType s_action;
        public Point2f[] vect;
        public EventType ev;
    }
    public enum EventType
    {
        ONE_SHOT,
        REAL_TIME,
        UNKNOWN
    }

    public enum ActionType
    {
        START,
        CONTINUE,
        STOP
    }

    public enum FingerType
    {
        ONE_FINGER,
        TWO_FINGERS,
        THREE_FINGERS,
        BIG_FINGER
    }
    public enum DirectionType
    {
        UP,     // + 
        DOWN,   // -
        LEFT,   // -
        RIGHT,  // +

        UP_LEFT,    // +   - 
        UP_RIGHT,   // +   +
        DOWN_LEFT,  // -   -
        DOWN_RIGHT, // -   +

        LEFT_UP,   // - 
        LEFT_DOWN, // +
        RIGHT_UP,  // +
        RIGHT_DOWN // -
    }
    public enum SenseType
    {
        POSITIVE,
        NEGATIVE
    }
    public enum MaterialType
    {
        SKIN,
        PAPER,
        CLOTHES,
        HAIR
    }
    public enum MovementType
    {
        STATIC,
        LINEAR,
        VERTICAL,
        SEMICIRCULAR,
        CIRCULAR,
        FREEHAND
    }
    public class TouchMouseEventArgs : EventArgs
    {
        public static float s_dist;     // -
        public static float s_velocity; // -
        public static int s_time; // -
        public static Point2f[] s_vect; // -
        public static EventType s_ev;
        public static ActionType s_action;
        public EventType eventType;     // missing real time
        public ActionType actionType;   // real time
        public MaterialType materialType;  // missing all materiasl
        public DirectionType directionType; // -
        public FingerType fingerType;       // -
        public MovementType movementType;   // *
        public SenseType senseType;         // -
        public Point2f[] vect;    // Depricated
        public float angs; // ¿¿¿ Y ESO QUE ES ???
        public float[] angles;
        public int time = 0;
        public float velocity = 0;
        public float distance = 0;
        public float certainty = 0; //*
        public bool valid = true;

        public override String ToString()
        {
            String s = "\nt " + time + "\n" +
                       "v " + velocity + "\n" +
                       "d " + distance + "\n" +
                      // "a " + angles[2] + "\n" +
                       "dir " + directionType + "\n";
            return s;
        }
        public TouchMouseEventArgs()
        {

        }
        public static void setDistSpeedTimeVect(DistSpeedTimeVect t)
        {
            s_dist = t.dist;
            s_velocity = t.speed;
            s_time = t.time;
            s_vect = t.vect;
            s_ev = t.ev;
            s_action = t.s_action;
        }
        public void setDistSpeedTimeVectM(DistSpeedTimeVect t)
        {
            distance = t.dist;
            velocity = t.speed;
            time = t.time;
            vect = t.vect;
            eventType = t.ev;
            actionType = t.s_action;
        }
        public static TouchMouseEventArgs herradura(DirectionType t, float[] ang)
        {
            TouchMouseEventArgs e = new TouchMouseEventArgs();
            e.actionType = s_action;
            e.certainty = 0.95f;
            e.directionType = t;
            e.velocity = s_velocity;
            e.distance = s_dist;
            e.eventType = s_ev;
            e.fingerType = FingerType.ONE_FINGER;
            e.angles = ang;
            e.materialType = MaterialType.SKIN;
            e.movementType = MovementType.SEMICIRCULAR;
            // set sense type
            e.senseType = getSemiCircularSenseTypeFromDirection(t);
            return e;
        }
        public static TouchMouseEventArgs Finger(DirectionType t, FingerType f)
        {
            TouchMouseEventArgs e = new TouchMouseEventArgs();
            e.actionType = s_action;
            e.certainty = 0.95f; // should be calculated
            e.directionType = t;
            e.distance = s_dist;
            e.velocity = s_velocity;
            e.eventType = s_ev;
            e.fingerType = f;
            e.angs = 0.0f;
            e.materialType = MaterialType.SKIN;
            e.movementType = MovementType.LINEAR;
            e.senseType = getLinealSenseTypeFromDirection(t);
            return e;
        }
        public static SenseType getLinealSenseTypeFromDirection(DirectionType d)
        {
            switch (d)
            {
                case DirectionType.DOWN:
                case DirectionType.DOWN_LEFT:
                case DirectionType.DOWN_RIGHT:
                case DirectionType.LEFT:
                    return SenseType.NEGATIVE;
                case DirectionType.UP:
                case DirectionType.RIGHT:
                case DirectionType.UP_LEFT:
                case DirectionType.UP_RIGHT:
                    return SenseType.POSITIVE;
            }
            //MessageBox.Show("Assert Error\n File TouchMouseEventArgs Delegate: getLinealSenseTypeFromDirection");
            return SenseType.POSITIVE;
        }
        public static SenseType getSemiCircularSenseTypeFromDirection(DirectionType d)
        {
            switch (d)
            {
                case DirectionType.LEFT_DOWN:
                case DirectionType.RIGHT_UP:
                case DirectionType.DOWN_RIGHT:
                case DirectionType.UP_RIGHT:
                    return SenseType.POSITIVE;
                case DirectionType.UP_LEFT:
                case DirectionType.DOWN_LEFT:
                case DirectionType.LEFT_UP:
                case DirectionType.RIGHT_DOWN:
                    return SenseType.NEGATIVE;
            }
            MessageBox.Show("Assert Error\n File TouchMouseEventArgs Delegate: getSemiCircularSenseTypeFromDirection");
            return SenseType.NEGATIVE;
        }

    }
}
